# Build recipe for tint2 
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=tint2
version=16.6
release=1
srcdir=tint2-16.2-b810bad93ff65854137fbd2f344ad2f99338008f 

tarname=${program}-${version}.tar.bz2

# Remote source(s)
#fetch=http://gitlab.com/o9000/tint2/-/archive/16.2/tint2-16.2.tar.bz2
fetch=http://gitlab.com/o9000/tint2/-/archive/16.2/"$tarname"

description="
tint2 is a simple panel/taskbar. 

It was  intentionally made for openbox3, but should also work with
other window managers.  It's based off ttm code.  The goal is to keep a
clean and unintrusive look with lightweight code and compliance with
freedesktop specifications.  On the first run, /etc/xdg/tint2/tint2rc
is copied to ~/.config/tint2/tint2rc and used as the default
configuration.
"


homepage=http://gitlab.com/o9000/tint2
license="GPLv2"

# Source documentation
docs="AUTHORS ChangeLog COPYING README.md"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    
    unpack "${tardir}/$tarname"

    cd "$srcdir"
    
    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_CXX_FLAGS:STRING="$QICXXFLAGS"  \
     -DCMAKE_EXE_LINKER_FLAGS:STRING="$QILDFLAGS"     \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$QILDFLAGS"  \
     -DCMAKE_INSTALL_PREFIX=/usr                      \
     -DLIB_SUFFIX=/usr/lib${libSuffix}                \
     -DCMAKE_INSTALL_MANDIR=$mandir                   \
     -DCMAKE_INSTALL_DOCDIR=$docsdir                  \
     -DCMAKE_BUILD_TYPE=Release                       \
     ..

    make -j${jobs} V=1 
    make -j${jobs} DESTDIR="$destdir" install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    
    # Leave the mkdir-build dir
    cd .. 
    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}/"
}


